package com.shiwaixiangcun.customer.utils

import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.util.Log
import com.shiwaixiangcun.customer.Common
import com.shiwaixiangcun.customer.module.heath.HealthEvaluationActivity
import com.shiwaixiangcun.customer.module.heath.HealthMainActivity
import com.shiwaixiangcun.customer.module.homeservice.HomeServiceMainActivity
import com.shiwaixiangcun.customer.module.housebutler.HouseButlerMainActivity
import com.shiwaixiangcun.customer.module.houserenting.HouseListActivity
import com.shiwaixiangcun.customer.module.houserenting.HouseRentingMainActivity
import com.shiwaixiangcun.customer.module.intelligent.FamilyInteractionActivity
import com.shiwaixiangcun.customer.module.property.PropertyPaymentActivity
import com.shiwaixiangcun.customer.module.ticket.TicketActivity
import com.shiwaixiangcun.customer.ui.activity.*

/**
 * Author   Administrator
 * Date     2018/1/24
 * Desc     界面点击工具类
 *
 */
object UIClickManager {

    val intent = Intent()
    val bundle = Bundle()

    /**
     * 首页工具栏点击跳转
     * （包括全部服务）
     */
    fun toolClick(context: Context?, type: String) {
        val isLogin = SharePreference.getStringSpParams(context, Common.ISORNOLOGIN, Common.SIORNOLOGIN)
        when (type) {
//          健康管理
            "HEALTH_MANAGEMENT" -> {
                if (LoginHelper.isLogin(context!!)) {
                    intent.setClass(context, HealthMainActivity::class.java)
                    context.startActivity(intent)
                } else {
                    intent.setClass(context, LoginActivity::class.java)
                    context.startActivity(intent)
                }

            }
//          健康测评
            "HEALTH_EVALUATION" -> {
                intent.setClass(context, HealthEvaluationActivity::class.java)
                context?.startActivity(intent)
            }
//          养生食谱
            "HEALTH_RECIPES" -> {
                bundle.putInt("current", 0)
                intent.setClass(context, RecipeActivity::class.java)
                intent.putExtras(bundle)
                context?.startActivity(intent, bundle)
            }
//          在线问诊
            "ORDINARY_TREAT" -> {
                if (Utils.isNotEmpty(isLogin)) {
                    intent.setClass(context, ChunyuDoctorActivity::class.java)
                    context?.startActivity(intent)
                } else {
                    intent.setClass(context, LoginActivity::class.java)
                    context?.startActivity(intent)
                }
            }
//          预约专家
            "EXPERT_APPOINTMENT" -> {
                intent.setClass(context, DoctorActivity::class.java)
                context?.startActivity(intent)
            }
//          铂金管家
            "HOUSEKEEPER" -> {
                intent.setClass(context, HouseButlerMainActivity::class.java)
                context?.startActivity(intent, bundle)
            }
//          消费维权
            "SAFEGUARD_RIGHTS" -> {
                intent.setClass(context, ProtectRightActivity::class.java)
                context?.startActivity(intent)
            }
//          社区公告
            "COMMUNITY_ANNOUNCEMENT" -> {
                intent.setClass(context, CommunityAnnouncementActivity::class.java)
                context?.startActivity(intent)
            }
//          周边生活
            "VICINITY_LIFE" -> {
                intent.setClass(context, SurroundLifeActivity::class.java)
                context?.startActivity(intent, bundle)
            }
//          到家服务
            "TO_HOME_SERVICE" -> {
                intent.setClass(context, HomeServiceMainActivity::class.java)
                context?.startActivity(intent)

            }
//          生活缴费
            "ONLINE_PAYMENT" -> {


                if (Utils.isNotEmpty(isLogin)) {

                    intent.setClass(context, PropertyPaymentActivity::class.java)
                    context?.startActivity(intent)
                } else {
                    intent.setClass(context, LoginActivity::class.java)
                    context?.startActivity(intent)
                }
            }
//          汽车票
            "BUS_TICKET" -> {
                intent.setClass(context, TicketActivity::class.java)
                context?.startActivity(intent)
            }
//          活动报名
            "ACTIVE_REGISTRATION" -> {
                intent.setClass(context, RegisterActivity::class.java)
                context?.startActivity(intent)
            }
//          房屋租售
            "HOUSE_RENTAL" -> {
                intent.setClass(context, HouseRentingMainActivity::class.java)
                context?.startActivity(intent)

            }
//          应急救助
            "EMERGENCY_RESCUE" -> {

                intent.setClass(context, EmergencyRescueActivity::class.java)
                context?.startActivity(intent)


            }
//          亲情互动
            "LOVE_INTERACTION" -> {


                if (LoginHelper.isLogin(context!!)) {
                    intent.setClass(context, FamilyInteractionActivity::class.java)
                    context.startActivity(intent)
                } else {
                    intent.setClass(context, LoginActivity::class.java)
                    context.startActivity(intent)
                }

            }

            "MORE" -> {
                intent.setClass(context, AllToolsActivity::class.java)
                context?.startActivity(intent)
            }

        //---------------------------------
        //---------------------------------
        //跳转到周边生活列表
        //---------------------------------
        //---------------------------------

        }

    }


    /**
     * 点击banner
     */
    fun bannerClick(context: Context?, type: String) {

        when (type) {

//          到家服务
            "TO_HOME_SERVICE" -> {
                intent.setClass(context, HomeServiceMainActivity::class.java)
                context?.startActivity(intent)
            }
//          房屋租售_首页
            "HOUSE_RENTAL" -> {
                intent.setClass(context, HouseRentingMainActivity::class.java)
                context?.startActivity(intent)

            }
//          房屋租售-二手房
            "SECOND_HAND_HOUSE" -> {


                bundle.putString("type", "saleHouse")
                intent.setClass(context, HouseListActivity::class.java)
                intent.putExtras(bundle)
                context?.startActivity(intent)
            }
//          房屋租售-租房
            "RENTING" -> {

                bundle.putString("type", "rentHouse")
                intent.setClass(context, HouseListActivity::class.java)
                intent.putExtras(bundle)
                context?.startActivity(intent)

            }
//          汽车票
            "BUS_TICKET" -> {
                intent.setClass(context, TicketActivity::class.java)
                context?.startActivity(intent)
            }
//          铂金管家
            "HOUSEKEEPER" -> {
                intent.setClass(context, HouseButlerMainActivity::class.java)
                context?.startActivity(intent)
            }
//          养生食谱
            "HEALTH_RECIPES" -> {
                bundle.putInt("current", 0)
                intent.setClass(context, RecipeActivity::class.java)
                intent.putExtras(bundle)
                context?.startActivity(intent, bundle)
            }
            else -> {

                Log.e("type", type)
                val merchant = type.substringAfter("_LIST_")
                val nameType = type.substringBefore("_LIST_")
                var type: String = ""
                type = when (nameType) {
                    "HOTEL" -> {
                        "酒店"
                    }
                    "FOOD" -> {
                        "美食"
                    }
                    else -> {
                        "酒店"
                    }
                }
                intent.setClass(context, SurroundTopActivity::class.java)
                intent.putExtra("merchant", merchant)
                intent.putExtra("nameType", type)
                context?.startActivity(intent)
            }


        }
    }


}